#include "cpu/exec/helper.h"
#include "cpu/decode/modrm.h"

/* for instruction encoding overloading */
#define DATA_TYPE 4
#define MSB(n) ((unsigned int)(n) >> ((DATA_TYPE << 3) - 1))
make_helper(cmp_rm2i_l){
	op_src->size=op_dest->size= 4;
	read_ModR_M(eip + 1, op_dest, op_src);
    //Log("%u\n",op_src->val);
	//Log("%u\n",op_src2->val);
	uint32_t i=swaddr_read(cpu.eip+2,1);
	uint32_t result = op_dest->val - i;
	//OPERAND_W(op_dest, result);
	//Log("%u\n",op_dest->val);Log("%u\n",i);
	//Log("%u\n",result);
	update_eflags_pf_zf_sf((int32_t)result);
	cpu.eflags.CF = result > op_dest->val;
	cpu.eflags.OF = MSB((op_dest->val ^ i) & (op_dest->val ^ result));
	
	cpu.eip+=3;
    return 0;
	//print_asm_template2();
}




